<?php
//require('Header_iframe.php');
include('../db_connect.php');

$remove_tutor=true;
$ulink=$_POST['removeAdminULink'];

$str_length=strlen($_POST['removeAdminULink']);
if($str_length<7 || $str_length >10 ){
	$remove_tutor=false;
    echo "Sorry, could not validate ULink ID.";
    return;
}

//make sure this user does exist
$sql="select user_id from fb_users where ulink_id='$ulink'";
$result = $db->Execute($sql);
$user_id = $result->fields['user_id'];
if(!$user_id)
{
    $remove_tutor=false;
    echo "Sorry, we can't find this user.";
    return;
}

//we are validated, remove the admin 
if($remove_tutor){ 
	$sql="update fb_users set reach_admin=0 where ulink_id='$ulink'";
	$db->Execute($sql);
	$sql="update mlf2_userdata set user_type=1 where user_id=$user_id";
	$db->Execute($sql);
    echo "Great success! $ulink is no longer an admin.";
}
?>
